package com.aaa.java15;

import com.aaa.utils.MyTools;

import java.io.*;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/7/19 11:26
 * @description：
 * @modified By：
 * @version:
 */
public class FileCopyBufferTest {
    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        MyTools.copyFile("D:\\xxx.mp4","G:\\ooo.mp4");
      /*  //从源文件拷贝到目标文件
        File fileSource = new File("D:\\xxx.mp4");
        //定义一个目标文件
        File fileTarget = new File("G:\\ooo.mp4");
        //读取源文件的内容
        FileInputStream fileInputStream = null;
        BufferedInputStream bufferedInputStream=null;
        FileOutputStream fileOutputStream = null;
        BufferedOutputStream bufferedOutputStream= null;
        try {
            fileInputStream = new FileInputStream(fileSource);
            bufferedInputStream= new BufferedInputStream(fileInputStream);
            //实例化输出流对象
            fileOutputStream = new FileOutputStream(fileTarget);
            bufferedOutputStream = new BufferedOutputStream(fileOutputStream);

            byte[] bytes = new byte[2048];
            int count = 0;

            while ((count = bufferedInputStream.read(bytes)) != -1) {
                bufferedOutputStream.write(bytes, 0, count);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            //关闭流
            try {
                bufferedOutputStream.close();
                bufferedInputStream.close();
                fileOutputStream.close();
                fileInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }

        }
*/
        long end = System.currentTimeMillis();
        System.out.println("时间花费："+(end-start));
    }
}
